eststo clear


if("`c(os)'"=="Windows"){
	local tableSaveDir = "Tables\"
	local plotSaveDir = "Plots\"
	local pythonSaveDir = "PythonScripts\"
}
else{
	local tableSaveDir = "Tables/"
	local plotSaveDir = "Plots/"
	local pythonSaveDir = "PythonScripts/"
}

//Establish Control Variable Sets
//Spec1 controls are the same for both registrations and VMT 
local spec1Controls = "c.normYear#i.stateGroup c.quadYear#i.stateGroup asinhMetroPop asinhNonMetroPop asinhMetroInc asinhNonMetroInc logrealmeangasprice logemployment loglicenseddrivers logrealstategdp logroadmileage"
local spec1LinearControls = "c.normYear#i.stateGroup asinhMetroPop asinhNonMetroPop asinhMetroInc asinhNonMetroInc logrealmeangasprice logemployment loglicenseddrivers logrealstategdp logroadmileage"

//Other controls are not the same for both registrations and VMT 
//Registration Controls
local spec2RegControls = "`spec1Controls' i.transactionDataDummy"
local spec3RegControls = "`spec2RegControls' i.regDummyExtSpec3"
local spec4RegControls = "`spec2RegControls' i.regDummyExtSpec4"

local spec2RegLinearControls = "`spec1LinearControls' i.transactionDataDummy"
local spec3RegLinearControls = "`spec2RegLinearControls' i.regDummyExtSpec3"
local spec4RegLinearControls = "`spec2RegLinearControls' i.regDummyExtSpec4"


di "`spec3RegControls'"

//VMT Controls
local spec2VMTControls = "`spec1Controls'"
local spec3VMTControls = "`spec2VMTControls' i.vmtDummyExtSpec3"
local spec4VMTControls = "`spec2VMTControls' i.vmtDummyExtSpec4"

local spec2VMTLinearControls = "`spec1LinearControls'"
local spec3VMTLinearControls = "`spec2VMTLinearControls' i.vmtDummyExtSpec3"
local spec4VMTLinearControls = "`spec2VMTLinearControls' i.vmtDummyExtSpec4"

//Absorb Vars are always time and state fixed effects
local absorbVars = "ib51.stateGroup ib1995.year"

//Establish Cluster Variable
local clusterVar = "stateGroup year"
// local clusterVar = "stateGroup"

//Establish primary null
local primaryNull = 1.6
local altNull = 1
local altNull2 = 0.3
local altNull3 = 0
local altNull4 = -2.5


local treatmentVar = "1.nosafetyind"

local fsOut = "logregistrations"
local rfOut = "logvmt"

local fsOutPerCapita = "logRegPerCapita"
local rfOutPerCapita = "logVMTPerCapita"

local fsControlsSpec1 = "`spec1Controls'"
local rfControlsSpec1 = "`spec1Controls'"

local fsControlsSpec1Linear = "`spec1LinearControls'"
local rfControlsSpec1Linear = "`spec1LinearControls'"

local treatControl = "nosafetyind"

local modelTitleSpec1 = "Spec1"
local modelTitleSpec1PerCapita = "Spec1PerCapita"
local modelTitleSpec1Linear = "Spec1Linear"
local nullLowSpec1 = -3.6
local nullDeltaSpec1 = 0.001
local nullHighSpec1 = 1

local fsControlsSpec2 = "`spec2RegControls'"
local rfControlsSpec2 = "`spec2VMTControls'"

local fsControlsSpec2Linear = "`spec2RegLinearControls'"
local rfControlsSpec2Linear = "`spec2VMTLinearControls'"

local treatControl = "nosafetyind"

local modelTitleSpec2 = "Spec2MultiCluster"
local nullLowSpec2 = -4
local nullDeltaSpec2 = 0.001
local nullHighSpec2 = 1

runModelFWL `fsOut', `rfOut', `fsControlsSpec2', `rfControlsSpec2', `treatControl', `absorbVars', `clusterVar', `treatmentVar', `modelTitleSpec2', `nullLowSpec1', `nullDeltaSpec1', `nullHighSpec1', `primaryNull', `altNull', `altNull2', `altNull3', `altNull4'
